import 'package:flutter/material.dart';

void main() {
  runApp(MaterialApp(
    home: Scaffold(
      appBar: AppBar(
        title: const Text("Indicator Demo"),
      ),
      body: AnimationProgressWidget(),
    ),
  ));
}

class AnimationProgressWidget extends StatefulWidget {
  @override
  _AnimationProgressWidgetState createState() => _AnimationProgressWidgetState();
}

class _AnimationProgressWidgetState
    extends State<AnimationProgressWidget> with SingleTickerProviderStateMixin {

  late AnimationController _animationController;


  @override
  void initState() {
    //  动画执行时间3秒
    _animationController = AnimationController(
      vsync: this,
      duration: const Duration(seconds: 3),
    );
    _animationController.forward();
    _animationController.addListener(() => setState(()=>{}));
    super.initState();
  }


  @override
  void dispose() {
    _animationController.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
     return SingleChildScrollView(
       child: Column(
         children: <Widget>[
           Padding(
             padding: const EdgeInsets.all(16),
             child: LinearProgressIndicator(
               backgroundColor: Colors.grey[200],
               valueColor: ColorTween(begin: Colors.grey, end: Colors.blue).animate(_animationController),
               value: _animationController.value,
             ),
           ),

         ],
       ),
     );
  }
}
